package top.wardyan.wmes.rfid.pub;

import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Path;

import top.wardyan.common.ctrl.BaseController;
import top.wardyan.wmes.rfid.kqa.dto.StationInfoDto;
import top.wardyan.wmes.rfid.kqa.dto.StationLoginDto;
import top.wardyan.wmes.rfid.kqa.dto.StationLoginStateDto;
import top.wardyan.wmes.rfid.kqa.vo.BaseRequest;
import top.wardyan.wmes.rfid.kqa.vo.BaseResponse;

/**
 * @author lcf
 * @CreateTime 2022/1/19 14:10
 * @Description 中间件站点
 */

@Path("/middleware-station/")
@SuppressWarnings("unchecked")
public class MiddlewareStationInfoController extends BaseController {
	private static final cn.hutool.log.Log log = cn.hutool.log.Log.get();
	
	
	@ActionKey("/middleware-station/login")
    public void stationLogin() {
        BaseRequest<StationLoginDto> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("中间件登录,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<StationLoginStateDto> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "{\"firstLoginTime\":\"2020/01/01 00:00:00\",\"isUse\":0,\"lastLogOutTime\":\"2020/01/01 00:00:00\",\"lastLoginTime\":\"2020/01/01 00:00:00\",\"lastStateUpdateTime\":\"2020/01/01 00:00:00\",\"loginName\":\"string\",\"loginUserID\":0,\"softWareName\":\"string\",\"softWareVersion\":\"string\",\"stationCode\":\"string\",\"stationID\":0,\"stationIP\":\"string\",\"stationLoginState\":0,\"stationName\":\"string\",\"stationPosition\":\"string\",\"userID\":0,\"userName\":\"string\",\"userType\":0}";
  		StationLoginStateDto dto = JSONObject.parseObject(s, StationLoginStateDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }

	
	
	
	
	@ActionKey("/middleware-station/get-all")
    public void getList() {
        BaseRequest<String> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("获取所有中间件列表,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<List<StationInfoDto>> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "[{\"firstLoginTime\":\"2020/01/01 00:00:00\",\"isUse\":0,\"lastLogOutTime\":\"2020/01/01 00:00:00\",\"lastLoginTime\":\"2020/01/01 00:00:00\",\"lastStateUpdateTime\":\"2020/01/01 00:00:00\",\"loginUserID\":0,\"remark\":\"string\",\"softWareName\":\"string\",\"softWareVersion\":\"string\",\"stationCode\":\"string\",\"stationID\":0,\"stationIP\":\"string\",\"stationLoginState\":0,\"stationName\":\"string\",\"stationPosition\":\"string\"}]";
  		List<StationInfoDto> dto = JSONArray.parseArray(s, StationInfoDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }

}
